/*
 * @Author: KG
 * @Date: 2024-12-13 14:32:01
 * @LastEditors: KG
 * @LastEditTime: 2024-12-13 16:35:22
 * @FilePath: \dk-world\public\native\modules\test.js
 * @Description:
 *
 */
let Test = {
  ssao: null,
  SkyLight: null,
  ExponentialHeightFog: null,
  SkyAtomosphere: null,
  VolumetricCloud: null,
  PostProcessVolume: null,
  ssaoFn: function (options = {}, cb) {
    const { amount = 0.5, radius = 1, quality = 1, enabled = true } = options;
    if (!Test.ssao) {
      Test.ssao = GlobalViewer.renderSystem.ssao;
    }
    if (amount != undefined) {
      Test.aaso.amount = amount;
    }
    if (radius != undefined) {
      Test.aaso.radius = radius;
    }
    if (quality != undefined) {
      Test.aaso.quality = quality;
    }
    if (enabled != undefined) {
      Test.aaso.enabled = enabled;
    }
  },
  skyLightFn: function (options = {}, cb) {
    const {
      intensityScale,
      indirectLightingIntensity,
      volumetricScatteringIntensity,
      color,
      realTimeCapture,
      lowerHemisphereIsSolidColor,
      lowerHemisphereColor,
      enabled,
    } = options;
    if (!Test.SkyLight) {
      Test.SkyLight = SSmap.SkyLight();
    }

    console.log("SkyLight", JSON.stringify(Test.SkyLight.realTimeCapture));
    if (intensityScale != undefined) {
      Test.SkyLight.intensityScale = intensityScale;

      console.log("intensityScale", intensityScale);
    }
    if (indirectLightingIntensity != undefined) {
      Test.SkyLight.indirectLightingIntensity = indirectLightingIntensity;
      console.log("indirectLightingIntensity", indirectLightingIntensity);
    }
    if (volumetricScatteringIntensity != undefined) {
      Test.SkyLight.volumetricScatteringIntensity =
        volumetricScatteringIntensity;
      console.log(
        "volumetricScatteringIntensity",
        volumetricScatteringIntensity
      );
    }
    if (realTimeCapture != undefined) {
      Test.SkyLight.realTimeCapture = realTimeCapture;
      console.log("realTimeCapture", realTimeCapture);
    }
    if (lowerHemisphereIsSolidColor != undefined) {
      Test.SkyLight.lowerHemisphereIsSolidColor = lowerHemisphereIsSolidColor;
      console.log("lowerHemisphereIsSolidColor", lowerHemisphereIsSolidColor);
    }
    // if (lowerHemisphereColor != undefined) {
    //   Test.SkyLight.intensityScale = intensityScale;
    // }
    if (enabled != undefined) {
      Test.SkyLight.enabled = enabled;
    }
    // color;
  },
  exponentialHeightFogFn: function (options = {}, cb) {
    const {
      fogDensity,
      fogHeightFalloff,
      secondFogDensity,
      secondFogHeightFalloff,
      secondFogHeightOffset,
      fogInscatteringColor,
      fogMaxOpacity,
      startDistance,
      fogCutoffDistance,
      directionalInscatteringExponent,
      directionlInscatteringStartDistance,
      directionalInscatteringColor,
    } = options;

    if (!Test.ExponentialHeightFog) {
      Test.ExponentialHeightFog = GlobalViewer.scene.exponentialHeightFog;
    }
    if (fogDensity != undefined) {
      Test.ExponentialHeightFog.fogDensity = fogDensity;
      console.log("fogDensity", fogDensity);
    }
    if (fogHeightFalloff != undefined) {
      Test.ExponentialHeightFog.fogHeightFalloff = fogHeightFalloff;
      console.log("fogHeightFalloff", fogHeightFalloff);
    }
    if (secondFogDensity != undefined) {
      Test.ExponentialHeightFog.secondFogDensity = secondFogDensity;
      console.log("secondFogDensity", secondFogDensity);
    }
    if (secondFogHeightFalloff != undefined) {
      Test.ExponentialHeightFog.secondFogHeightFalloff = secondFogHeightFalloff;
      console.log("secondFogHeightFalloff", secondFogHeightFalloff);
    }
    if (secondFogHeightOffset != undefined) {
      Test.ExponentialHeightFog.secondFogHeightOffset = secondFogHeightOffset;
      console.log("secondFogHeightOffset", secondFogHeightOffset);
    }
    if (fogInscatteringColor != undefined) {
      Test.ExponentialHeightFog.fogInscatteringColor = fogInscatteringColor;
      console.log("fogInscatteringColor", fogInscatteringColor);
    }
    if (fogMaxOpacity != undefined) {
      Test.ExponentialHeightFog.fogMaxOpacity = fogMaxOpacity;
      console.log("fogMaxOpacity", fogMaxOpacity);
    }
    if (startDistance != undefined) {
      Test.ExponentialHeightFog.startDistance = startDistance;
      console.log("startDistance", startDistance);
    }
    if (fogCutoffDistance != undefined) {
      Test.ExponentialHeightFog.fogCutoffDistance = fogCutoffDistance;
      console.log("fogCutoffDistance", fogCutoffDistance);
    }
    if (directionalInscatteringExponent != undefined) {
      Test.ExponentialHeightFog.directionalInscatteringExponent =
        directionalInscatteringExponent;
      console.log(
        "directionalInscatteringExponent",
        directionalInscatteringExponent
      );
    }
    if (directionlInscatteringStartDistance != undefined) {
      Test.ExponentialHeightFog.directionlInscatteringStartDistance =
        directionlInscatteringStartDistance;
      console.log(
        "directionlInscatteringStartDistance",
        directionlInscatteringStartDistance
      );
    }
    if (directionalInscatteringColor != undefined) {
      Test.ExponentialHeightFog.directionalInscatteringColor =
        directionalInscatteringColor;
      console.log("directionalInscatteringColor", directionalInscatteringColor);
    }
  },
  //   skyAtomosphereFn: function (options = {}, cb) {
  // const {} = options;
  // const {
  //   groundAlbedo = SSmap.Color.fromRgb(170, 170, 170, 255),
  //   multiScatteringFactor = 1.0,
  //   reyleighScatteringScale = 0.0331, //0~2
  //   rayleighScattering = SSmap.Vector3.create(
  //     0.17528699927767638,
  //     0.40960724187397174,
  //     1
  //   ), // -1000~1000
  //   rayleighExponentialDistribution = 8, //0.01~20
  //   mieScatteringScale = 0.003996, //0~5
  //   mieScattering = SSmap.Vector3.create(1.0, 1.0, 1.0), // -1000~1000
  //   mieaAbsorptionScale = 0.000444, //0~5
  //   mieAbsorption = SSmap.Vector3.create(1.0, 1.0, 1.0), // -1000~1000
  //   mieAnisotropy = 0.8, //0~0.999
  //   mieExponentialDistribution = 1.2, //0.01~10
  //   otherAbsorptionScale = 0.001881, //0~0.2
  //   otherAbsorption = SSmap.Vector3.create(
  //     0.3455608721234321,
  //     1.0,
  //     0.04518872913977076
  //   ), // -1000~1000
  //   skyLuminanceFactor = SSmap.Vector3.create(1.0, 1.0, 1.0), // -1000~1000
  //   aerialPerspectiveViewDistanceScale = 1.0, // 0~3
  //   heightFogContribution = 1, //0~1
  //   transmittanceMinLightElevationAngle = -90, //-90 ~ 90
  //   aerialPerspectiveStartDepth = 0.1, //0.001~10
  //   enabled = true,
  // } = options;
  //   },

  postProcessVolumeFn: function (options, cb) {
    const {
      // LightShafts;
      useLightShaftsOcclusion,
      occlusionMaskDarkness,
      occlusionDepthRange,
      useLightShaftsBloom,
      bloomScale,
      lightShaftsBloomThreshold,
      bloomMaxBrightness,
      bloomTint,
      //   MotionBlur
      useMotionBlur,
      motionBlurAmount,

      //   Bloom;
      useBloom,
      bloomIntensity,
      bloomThreshold,
      //   Exposure;
      useEyeAdaptation,
      exposureCompensation,
      autoExposureMinBrightness,
      autoExposureMaxBrightness,
      autoExposureSpeedUp,
      autoExposureSpeedDown,

      //  LensFlares;
      useLensFlare,
      lensFlareIntensity,
      lensFlareTint,
      lensFlareBokehSize,
      lensFlareThreshold,
      // ToneMapping
      useToneMapping,

      filmSlope,
      filmToe,
      filmShoulder,
      filmBlackClip,
      filmWhiteClip,
    } = options || {};

    if (!Test.PostProcessVolume) {
      Test.PostProcessVolume = new SSmap.PostProcessVolume();
    }

    if (useLightShaftsOcclusion != undefined) {
      Test.PostProcessVolume.useLightShaftsOcclusion = useLightShaftsOcclusion;
      console.log("useLightShaftsOcclusion", useLightShaftsOcclusion);
    }
    if (occlusionMaskDarkness != undefined) {
      Test.PostProcessVolume.occlusionMaskDarkness = occlusionMaskDarkness;
      console.log("occlusionMaskDarkness", occlusionMaskDarkness);
    }
    if (occlusionDepthRange != undefined) {
      Test.PostProcessVolume.occlusionDepthRange = occlusionDepthRange;
      console.log("occlusionDepthRange", occlusionDepthRange);
    }
    if (useLightShaftsBloom != undefined) {
      Test.PostProcessVolume.useLightShaftsBloom = useLightShaftsBloom;
      console.log("useLightShaftsBloom", useLightShaftsBloom);
    }
    if (bloomScale != undefined) {
      Test.PostProcessVolume.bloomScale = bloomScale;
      console.log("bloomScale", bloomScale);
    }
    if (lightShaftsBloomThreshold != undefined) {
      Test.PostProcessVolume.lightShaftsBloomThreshold =
        lightShaftsBloomThreshold;
      console.log("lightShaftsBloomThreshold", lightShaftsBloomThreshold);
    }
    if (bloomMaxBrightness != undefined) {
      Test.PostProcessVolume.bloomMaxBrightness = bloomMaxBrightness;
      console.log("bloomMaxBrightness", bloomMaxBrightness);
    }
    if (bloomTint != undefined) {
      Test.PostProcessVolume.bloomTint = bloomTint;
      console.log("bloomTint", bloomTint);
    }
    if (useMotionBlur != undefined) {
      Test.PostProcessVolume.useMotionBlur = useMotionBlur;
      console.log("useMotionBlur", useMotionBlur);
    }
    if (motionBlurAmount != undefined) {
      Test.PostProcessVolume.motionBlurAmount = motionBlurAmount;
      console.log("motionBlurAmount", motionBlurAmount);
    }
    if (useBloom != undefined) {
      Test.PostProcessVolume.useBloom = useBloom;
      console.log("useBloom", useBloom);
    }
    if (bloomIntensity != undefined) {
      Test.PostProcessVolume.bloomIntensity = bloomIntensity;
      console.log("bloomIntensity", bloomIntensity);
    }
    if (bloomThreshold != undefined) {
      Test.PostProcessVolume.bloomThreshold = bloomThreshold;
      console.log("bloomThreshold", bloomThreshold);
    }

    if (useEyeAdaptation != undefined) {
      Test.PostProcessVolume.useEyeAdaptation = useEyeAdaptation;
      console.log("useEyeAdaptation", useEyeAdaptation);
    }
    if (exposureCompensation != undefined) {
      Test.PostProcessVolume.exposureCompensation = exposureCompensation;
      console.log("exposureCompensation", exposureCompensation);
    }
    if (autoExposureMinBrightness != undefined) {
      Test.PostProcessVolume.autoExposureMinBrightness =
        autoExposureMinBrightness;
      console.log("autoExposureMinBrightness", autoExposureMinBrightness);
    }
    if (autoExposureMaxBrightness != undefined) {
      Test.PostProcessVolume.autoExposureMaxBrightness =
        autoExposureMaxBrightness;
      console.log("autoExposureMaxBrightness", autoExposureMaxBrightness);
    }
    if (autoExposureSpeedUp != undefined) {
      Test.PostProcessVolume.autoExposureSpeedUp = autoExposureSpeedUp;
      console.log("autoExposureSpeedUp", autoExposureSpeedUp);
    }
    if (autoExposureSpeedDown != undefined) {
      Test.PostProcessVolume.autoExposureSpeedDown = autoExposureSpeedDown;
      console.log("autoExposureSpeedDown", autoExposureSpeedDown);
    }

    if (useLensFlare != undefined) {
      Test.PostProcessVolume.useLensFlare = useLensFlare;
      console.log("useLensFlare", useLensFlare);
    }
    if (lensFlareIntensity != undefined) {
      Test.PostProcessVolume.lensFlareIntensity = lensFlareIntensity;
      console.log("lensFlareIntensity", lensFlareIntensity);
    }
    if (lensFlareTint != undefined) {
      Test.PostProcessVolume.lensFlareTint = lensFlareTint;
      console.log("lensFlareTint", lensFlareTintpeedDown);
    }
    if (lensFlareBokehSize != undefined) {
      Test.PostProcessVolume.lensFlareBokehSize = lensFlareBokehSize;
      console.log("lensFlareBokehSize", lensFlareBokehSize);
    }
    if (lensFlareThreshold != undefined) {
      Test.PostProcessVolume.lensFlareThreshold = lensFlareThreshold;
      console.log("lensFlareThreshold", lensFlareThreshold);
    }

    if (useToneMapping != undefined) {
      Test.PostProcessVolume.useToneMapping = useToneMapping;
      console.log("useToneMapping", useToneMapping);
    }

    if (filmSlope != undefined) {
      Test.PostProcessVolume.filmSlope = filmSlope;
      console.log("filmSlope", filmSlope);
    }
    if (filmToe != undefined) {
      Test.PostProcessVolume.filmToe = filmToe;
      console.log("filmToe", filmToe);
    }
    if (filmShoulder != undefined) {
      Test.PostProcessVolume.filmShoulder = filmShoulder;
      console.log("filmShoulder", filmShoulder);
    }
    if (filmBlackClip != undefined) {
      Test.PostProcessVolume.filmBlackClip = filmBlackClip;
      console.log("filmBlackClip", filmBlackClip);
    }
    if (filmWhiteClip != undefined) {
      Test.PostProcessVolume.filmWhiteClip = filmWhiteClip;
      console.log("filmWhiteClip", filmWhiteClip);
    }
  },
};

export { Test };
